package com.usian.service.impl;

import com.usian.mapper.BumenMapper;
import com.usian.mapper.CompanyMapper;
import com.usian.pojo.Bumen;
import com.usian.pojo.Staff;
import com.usian.service.BumenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BumenServiceImpl implements BumenService {

    @Autowired
    private BumenMapper bumenMapper;

    @Override
    public List<Bumen> findAll() {
        return bumenMapper.selectAll();
    }

    @Override
    public void add(Bumen bumen) {
        bumenMapper.insert(bumen);
    }

    @Override
    public Bumen findById(Integer bid) {
        return bumenMapper.findById(bid);
    }

    @Override
    public void update(Bumen bumen) {
          bumenMapper.updateByPrimaryKeySelective(bumen);

    }

    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public boolean del(Integer bid) {
        List<Staff> staff =  companyMapper.findByBid(bid);
        if (staff==null){
            bumenMapper.deleteByPrimaryKey(bid);
        }
        return false;
    }
}
